package com.marvels.loanapply.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.loanapply.api.LoanapplyAttachAchieveApi;
import com.marvels.loanapply.api.LoanExtDataApi;
import com.marvels.loanapply.channel.dto.UserChannelInfoParamDTO;
import com.marvels.loanapply.channel.dto.UserChannelInfoResultDTO;
import com.marvels.loanapply.dto.ApprovalProcessConditionDTO;
import com.marvels.loanapply.dto.ApprovalProcessInfoDTO;
import com.marvels.loanapply.dto.LaAttachAtmeTypeViewDTO;
import com.marvels.loanapply.dto.LaAttachmentDto;
import com.marvels.loanapply.dto.LoanExtDataDTO;
import com.marvels.loanapply.dto.MclaProtocolTemplateInfoDTO;

@RestController
@RequestMapping("/loanApply/api")
public class ApplyProvideController {
	
	@Autowired
	private LoanapplyAttachAchieveApi attachAchieveApi;
	
	@Autowired
	private LoanExtDataApi loanExtDataApi;
	
	@RequestMapping("/achieveAttachInfo")
	@ResponseBody
    public List<LaAttachmentDto> achieveAttachInfo(@RequestBody LaAttachmentDto laAttachmentDto) {
        return attachAchieveApi.achieveAttachInfo(laAttachmentDto.getAtmtTypes(), laAttachmentDto.getLoanIds(),laAttachmentDto.getFileIds());
    }
	
	
	
	
	@RequestMapping("/compactAttach")
	@ResponseBody
    public List<LaAttachmentDto> compactAttach(@RequestBody LaAttachmentDto laAttachmentDto) {
        return attachAchieveApi.compactAttach(laAttachmentDto.getFileIds(), laAttachmentDto.getLoanIds());
    }
	
	
	@RequestMapping("/getAttachAtmeTypeInfo")
	@ResponseBody
    public List<LaAttachAtmeTypeViewDTO> getAttachAtmeTypeInfo(@RequestBody LaAttachAtmeTypeViewDTO laAttachAtmeTypeViewDTO) {
		MarvelsLogUtil.getInstance().info("data : " + laAttachAtmeTypeViewDTO.toString());
        return attachAchieveApi.getAttachAtmeTypeInfo(laAttachAtmeTypeViewDTO);
    }
	@RequestMapping("/selectMclaProtocolTemplateInfo")
	@ResponseBody
	public MclaProtocolTemplateInfoDTO selectMclaProtocolTemplateInfo(String templateNo) {
		return attachAchieveApi.selectMclaProtocolTemplateInfo(templateNo);
	}
	
	
	@RequestMapping("selectLoanStateNameById")
	@ResponseBody
	public String selectLoanStateNameById(@RequestBody String stateId){
		return loanExtDataApi.selectLoanStateNameById(stateId);
	}
	
	/**
	 * 查询订单扩展信息
	 * @param loanExtDataDTO
	 * @return
	 */
	@RequestMapping("selectLoanExtData")
	@ResponseBody
	public LoanExtDataDTO selectLoanExtData(@RequestBody LoanExtDataDTO loanExtDataDTO){
		return loanExtDataApi.selectLoanExtData(loanExtDataDTO);
	}
	
	
	/**
	 * 获取入驻渠道列表
	 * @param dto
	 * @return
	 */
	@RequestMapping("selectUserChannelList")
	@ResponseBody
	public List<UserChannelInfoResultDTO> selectUserChannelList(@RequestBody UserChannelInfoParamDTO dto){
		return loanExtDataApi.selectUserChannelList(dto);
	}
	
	/**
	 * 进件列表查询
	 * @param dto
	 * @return
	 */
	@RequestMapping("loanListQuery")
	@ResponseBody
	public PageInfo<ApprovalProcessInfoDTO> loanListQuery(@RequestBody ApprovalProcessConditionDTO dto){
		return loanExtDataApi.loanListQuery(dto);
	}
}